<template>
  <div class="tab-control">
    <div
      class="tab-control-item"
      v-for="(item, index) in titles"
      :class="{ active: isIndex === index }"
      @click="indexIng(index)"
    >
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      isIndex: 0,
    };
  },
  methods: {
    indexIng(index) {
      this.isIndex = index
      this.$emit('indexClick', index)
    }
  }
};
</script>

<style scoped>
.tab-control {
  display: flex;
  text-align: center;
  height: 40px;
  line-height: 40px;
  background-color: #fff;
  font-size: 15px;
}

.tab-control-item {
  flex: 1;
}

.tab-control-item span {
  padding: 3px;
}

.tab-control-item.active span{
  color: rgb(255, 142, 150);
  border-bottom: 3px solid rgb(255, 142, 150);
}
</style>